\(\int \frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x^2} \, dx\) [494]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [C] (verification not implemented)
   Sympy [F]
   Maxima [F]
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 23, antiderivative size = 287 \[ \int \frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x^2} \, dx=-\frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x}+\frac {3 \sqrt {1+x} \sqrt {1-x+x^2}}{1+\sqrt {3}+x}-\frac {3 \sqrt [4]{3} \sqrt {2-\sqrt {3}} (1+x)^{3/2} \sqrt {1-x+x^2} \sqrt {\frac {1-x+x^2}{\left (1+\sqrt {3}+x\right )^2}} E\left (\arcsin \left (\frac {1-\sqrt {3}+x}{1+\sqrt {3}+x}\right )|-7-4 \sqrt {3}\right )}{2 \sqrt {\frac {1+x}{\left (1+\sqrt {3}+x\right )^2}} \left (1+x^3\right )}+\frac {\sqrt {2} 3^{3/4} (1+x)^{3/2} \sqrt {1-x+x^2} \sqrt {\frac {1-x+x^2}{\left (1+\sqrt {3}+x\right )^2}} \operatorname {EllipticF}\left (\arcsin \left (\frac {1-\sqrt {3}+x}{1+\sqrt {3}+x}\right ),-7-4 \sqrt {3}\right )}{\sqrt {\frac {1+x}{\left (1+\sqrt {3}+x\right )^2}} \left (1+x^3\right )} \]

[Out]

-(1+x)^(1/2)*(x^2-x+1)^(1/2)/x+3*(1+x)^(1/2)*(x^2-x+1)^(1/2)/(1+x+3^(1/2))+3^(3/4)*(1+x)^(3/2)*EllipticF((1+x-
3^(1/2))/(1+x+3^(1/2)),I*3^(1/2)+2*I)*2^(1/2)*(x^2-x+1)^(1/2)*((x^2-x+1)/(1+x+3^(1/2))^2)^(1/2)/(x^3+1)/((1+x)
/(1+x+3^(1/2))^2)^(1/2)-3/2*3^(1/4)*(1+x)^(3/2)*EllipticE((1+x-3^(1/2))/(1+x+3^(1/2)),I*3^(1/2)+2*I)*(x^2-x+1)
^(1/2)*(1/2*6^(1/2)-1/2*2^(1/2))*((x^2-x+1)/(1+x+3^(1/2))^2)^(1/2)/(x^3+1)/((1+x)/(1+x+3^(1/2))^2)^(1/2)

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 287, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.217, Rules used = {929, 283, 309, 224, 1891} \[ \int \frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x^2} \, dx=\frac {\sqrt {2} 3^{3/4} \sqrt {x^2-x+1} \sqrt {\frac {x^2-x+1}{\left (x+\sqrt {3}+1\right )^2}} (x+1)^{3/2} \operatorname {EllipticF}\left (\arcsin \left (\frac {x-\sqrt {3}+1}{x+\sqrt {3}+1}\right ),-7-4 \sqrt {3}\right )}{\sqrt {\frac {x+1}{\left (x+\sqrt {3}+1\right )^2}} \left (x^3+1\right )}-\frac {3 \sqrt [4]{3} \sqrt {2-\sqrt {3}} \sqrt {x^2-x+1} \sqrt {\frac {x^2-x+1}{\left (x+\sqrt {3}+1\right )^2}} (x+1)^{3/2} E\left (\arcsin \left (\frac {x-\sqrt {3}+1}{x+\sqrt {3}+1}\right )|-7-4 \sqrt {3}\right )}{2 \sqrt {\frac {x+1}{\left (x+\sqrt {3}+1\right )^2}} \left (x^3+1\right )}-\frac {\sqrt {x^2-x+1} \sqrt {x+1}}{x}+\frac {3 \sqrt {x^2-x+1} \sqrt {x+1}}{x+\sqrt {3}+1} \]

[In]

Int[(Sqrt[1 + x]*Sqrt[1 - x + x^2])/x^2,x]

[Out]

-((Sqrt[1 + x]*Sqrt[1 - x + x^2])/x) + (3*Sqrt[1 + x]*Sqrt[1 - x + x^2])/(1 + Sqrt[3] + x) - (3*3^(1/4)*Sqrt[2
 - Sqrt[3]]*(1 + x)^(3/2)*Sqrt[1 - x + x^2]*Sqrt[(1 - x + x^2)/(1 + Sqrt[3] + x)^2]*EllipticE[ArcSin[(1 - Sqrt
[3] + x)/(1 + Sqrt[3] + x)], -7 - 4*Sqrt[3]])/(2*Sqrt[(1 + x)/(1 + Sqrt[3] + x)^2]*(1 + x^3)) + (Sqrt[2]*3^(3/
4)*(1 + x)^(3/2)*Sqrt[1 - x + x^2]*Sqrt[(1 - x + x^2)/(1 + Sqrt[3] + x)^2]*EllipticF[ArcSin[(1 - Sqrt[3] + x)/
(1 + Sqrt[3] + x)], -7 - 4*Sqrt[3]])/(Sqrt[(1 + x)/(1 + Sqrt[3] + x)^2]*(1 + x^3))

Rule 224

Int[1/Sqrt[(a_) + (b_.)*(x_)^3], x_Symbol] :> With[{r = Numer[Rt[b/a, 3]], s = Denom[Rt[b/a, 3]]}, Simp[2*Sqrt
[2 + Sqrt[3]]*(s + r*x)*(Sqrt[(s^2 - r*s*x + r^2*x^2)/((1 + Sqrt[3])*s + r*x)^2]/(3^(1/4)*r*Sqrt[a + b*x^3]*Sq
rt[s*((s + r*x)/((1 + Sqrt[3])*s + r*x)^2)]))*EllipticF[ArcSin[((1 - Sqrt[3])*s + r*x)/((1 + Sqrt[3])*s + r*x)
], -7 - 4*Sqrt[3]], x]] /; FreeQ[{a, b}, x] && PosQ[a]

Rule 283

Int[((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[(c*x)^(m + 1)*((a + b*x^n)^p/(c*(m + 1
))), x] - Dist[b*n*(p/(c^n*(m + 1))), Int[(c*x)^(m + n)*(a + b*x^n)^(p - 1), x], x] /; FreeQ[{a, b, c}, x] &&
IGtQ[n, 0] && GtQ[p, 0] && LtQ[m, -1] &&  !ILtQ[(m + n*p + n + 1)/n, 0] && IntBinomialQ[a, b, c, n, m, p, x]

Rule 309

Int[(x_)/Sqrt[(a_) + (b_.)*(x_)^3], x_Symbol] :> With[{r = Numer[Rt[b/a, 3]], s = Denom[Rt[b/a, 3]]}, Dist[(-(
1 - Sqrt[3]))*(s/r), Int[1/Sqrt[a + b*x^3], x], x] + Dist[1/r, Int[((1 - Sqrt[3])*s + r*x)/Sqrt[a + b*x^3], x]
, x]] /; FreeQ[{a, b}, x] && PosQ[a]

Rule 929

Int[((g_.)*(x_))^(n_)*((d_.) + (e_.)*(x_))^(m_)*((a_) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_), x_Symbol] :> Dist[(d
+ e*x)^FracPart[p]*((a + b*x + c*x^2)^FracPart[p]/(a*d + c*e*x^3)^FracPart[p]), Int[(g*x)^n*(a*d + c*e*x^3)^p,
 x], x] /; FreeQ[{a, b, c, d, e, g, m, n, p}, x] && EqQ[m - p, 0] && EqQ[b*d + a*e, 0] && EqQ[c*d + b*e, 0]

Rule 1891

Int[((c_) + (d_.)*(x_))/Sqrt[(a_) + (b_.)*(x_)^3], x_Symbol] :> With[{r = Numer[Simplify[(1 - Sqrt[3])*(d/c)]]
, s = Denom[Simplify[(1 - Sqrt[3])*(d/c)]]}, Simp[2*d*s^3*(Sqrt[a + b*x^3]/(a*r^2*((1 + Sqrt[3])*s + r*x))), x
] - Simp[3^(1/4)*Sqrt[2 - Sqrt[3]]*d*s*(s + r*x)*(Sqrt[(s^2 - r*s*x + r^2*x^2)/((1 + Sqrt[3])*s + r*x)^2]/(r^2
*Sqrt[a + b*x^3]*Sqrt[s*((s + r*x)/((1 + Sqrt[3])*s + r*x)^2)]))*EllipticE[ArcSin[((1 - Sqrt[3])*s + r*x)/((1
+ Sqrt[3])*s + r*x)], -7 - 4*Sqrt[3]], x]] /; FreeQ[{a, b, c, d}, x] && PosQ[a] && EqQ[b*c^3 - 2*(5 - 3*Sqrt[3
])*a*d^3, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {\left (\sqrt {1+x} \sqrt {1-x+x^2}\right ) \int \frac {\sqrt {1+x^3}}{x^2} \, dx}{\sqrt {1+x^3}} \\ & = -\frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x}+\frac {\left (3 \sqrt {1+x} \sqrt {1-x+x^2}\right ) \int \frac {x}{\sqrt {1+x^3}} \, dx}{2 \sqrt {1+x^3}} \\ & = -\frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x}+\frac {\left (3 \sqrt {1+x} \sqrt {1-x+x^2}\right ) \int \frac {1-\sqrt {3}+x}{\sqrt {1+x^3}} \, dx}{2 \sqrt {1+x^3}}+\frac {\left (3 \left (-1+\sqrt {3}\right ) \sqrt {1+x} \sqrt {1-x+x^2}\right ) \int \frac {1}{\sqrt {1+x^3}} \, dx}{2 \sqrt {1+x^3}} \\ & = -\frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x}+\frac {3 \sqrt {1+x} \sqrt {1-x+x^2}}{1+\sqrt {3}+x}-\frac {3 \sqrt [4]{3} \sqrt {2-\sqrt {3}} (1+x)^{3/2} \sqrt {1-x+x^2} \sqrt {\frac {1-x+x^2}{\left (1+\sqrt {3}+x\right )^2}} E\left (\sin ^{-1}\left (\frac {1-\sqrt {3}+x}{1+\sqrt {3}+x}\right )|-7-4 \sqrt {3}\right )}{2 \sqrt {\frac {1+x}{\left (1+\sqrt {3}+x\right )^2}} \left (1+x^3\right )}+\frac {\sqrt {2} 3^{3/4} (1+x)^{3/2} \sqrt {1-x+x^2} \sqrt {\frac {1-x+x^2}{\left (1+\sqrt {3}+x\right )^2}} F\left (\sin ^{-1}\left (\frac {1-\sqrt {3}+x}{1+\sqrt {3}+x}\right )|-7-4 \sqrt {3}\right )}{\sqrt {\frac {1+x}{\left (1+\sqrt {3}+x\right )^2}} \left (1+x^3\right )} \\ \end{align*}

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 10.30 (sec) , antiderivative size = 349, normalized size of antiderivative = 1.22 \[ \int \frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x^2} \, dx=-\frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x}+\frac {3 \sqrt {1+\frac {2 i (1+x)}{-3 i+\sqrt {3}}} \sqrt {1-\frac {2 i (1+x)}{3 i+\sqrt {3}}} \left (-\frac {\left (-3 i+\sqrt {3}\right ) \sqrt {-\frac {i}{3 i+\sqrt {3}}} \sqrt {1+x} E\left (i \text {arcsinh}\left (\sqrt {2} \sqrt {-\frac {i (1+x)}{3 i+\sqrt {3}}}\right )|\frac {3 i+\sqrt {3}}{3 i-\sqrt {3}}\right )}{\sqrt {-\frac {i (1+x)}{3 i+\sqrt {3}}}}+\frac {\left (-i+\sqrt {3}\right ) \sqrt {-\frac {i}{3 i+\sqrt {3}}} \sqrt {1+x} \operatorname {EllipticF}\left (i \text {arcsinh}\left (\sqrt {2} \sqrt {-\frac {i (1+x)}{3 i+\sqrt {3}}}\right ),\frac {3 i+\sqrt {3}}{3 i-\sqrt {3}}\right )}{\sqrt {-\frac {i (1+x)}{3 i+\sqrt {3}}}}\right )}{2 \sqrt {2} \sqrt {-\frac {i}{3 i+\sqrt {3}}} \sqrt {3-3 (1+x)+(1+x)^2}} \]

[In]

Integrate[(Sqrt[1 + x]*Sqrt[1 - x + x^2])/x^2,x]

[Out]

-((Sqrt[1 + x]*Sqrt[1 - x + x^2])/x) + (3*Sqrt[1 + ((2*I)*(1 + x))/(-3*I + Sqrt[3])]*Sqrt[1 - ((2*I)*(1 + x))/
(3*I + Sqrt[3])]*(-(((-3*I + Sqrt[3])*Sqrt[(-I)/(3*I + Sqrt[3])]*Sqrt[1 + x]*EllipticE[I*ArcSinh[Sqrt[2]*Sqrt[
((-I)*(1 + x))/(3*I + Sqrt[3])]], (3*I + Sqrt[3])/(3*I - Sqrt[3])])/Sqrt[((-I)*(1 + x))/(3*I + Sqrt[3])]) + ((
-I + Sqrt[3])*Sqrt[(-I)/(3*I + Sqrt[3])]*Sqrt[1 + x]*EllipticF[I*ArcSinh[Sqrt[2]*Sqrt[((-I)*(1 + x))/(3*I + Sq
rt[3])]], (3*I + Sqrt[3])/(3*I - Sqrt[3])])/Sqrt[((-I)*(1 + x))/(3*I + Sqrt[3])]))/(2*Sqrt[2]*Sqrt[(-I)/(3*I +
 Sqrt[3])]*Sqrt[3 - 3*(1 + x) + (1 + x)^2])

Maple [A] (verified)

Time = 0.63 (sec) , antiderivative size = 216, normalized size of antiderivative = 0.75

method result size
elliptic \(\frac {\sqrt {\left (1+x \right ) \left (x^{2}-x +1\right )}\, \left (-\frac {\sqrt {x^{3}+1}}{x}+\frac {3 \left (\frac {3}{2}-\frac {i \sqrt {3}}{2}\right ) \sqrt {\frac {1+x}{\frac {3}{2}-\frac {i \sqrt {3}}{2}}}\, \sqrt {\frac {x -\frac {1}{2}-\frac {i \sqrt {3}}{2}}{-\frac {3}{2}-\frac {i \sqrt {3}}{2}}}\, \sqrt {\frac {x -\frac {1}{2}+\frac {i \sqrt {3}}{2}}{-\frac {3}{2}+\frac {i \sqrt {3}}{2}}}\, \left (\left (-\frac {3}{2}-\frac {i \sqrt {3}}{2}\right ) E\left (\sqrt {\frac {1+x}{\frac {3}{2}-\frac {i \sqrt {3}}{2}}}, \sqrt {\frac {-\frac {3}{2}+\frac {i \sqrt {3}}{2}}{-\frac {3}{2}-\frac {i \sqrt {3}}{2}}}\right )+\left (\frac {1}{2}+\frac {i \sqrt {3}}{2}\right ) F\left (\sqrt {\frac {1+x}{\frac {3}{2}-\frac {i \sqrt {3}}{2}}}, \sqrt {\frac {-\frac {3}{2}+\frac {i \sqrt {3}}{2}}{-\frac {3}{2}-\frac {i \sqrt {3}}{2}}}\right )\right )}{\sqrt {x^{3}+1}}\right )}{\sqrt {1+x}\, \sqrt {x^{2}-x +1}}\) \(216\)
risch \(-\frac {\sqrt {1+x}\, \sqrt {x^{2}-x +1}}{x}+\frac {3 \left (\frac {3}{2}-\frac {i \sqrt {3}}{2}\right ) \sqrt {\frac {1+x}{\frac {3}{2}-\frac {i \sqrt {3}}{2}}}\, \sqrt {\frac {x -\frac {1}{2}-\frac {i \sqrt {3}}{2}}{-\frac {3}{2}-\frac {i \sqrt {3}}{2}}}\, \sqrt {\frac {x -\frac {1}{2}+\frac {i \sqrt {3}}{2}}{-\frac {3}{2}+\frac {i \sqrt {3}}{2}}}\, \left (\left (-\frac {3}{2}-\frac {i \sqrt {3}}{2}\right ) E\left (\sqrt {\frac {1+x}{\frac {3}{2}-\frac {i \sqrt {3}}{2}}}, \sqrt {\frac {-\frac {3}{2}+\frac {i \sqrt {3}}{2}}{-\frac {3}{2}-\frac {i \sqrt {3}}{2}}}\right )+\left (\frac {1}{2}+\frac {i \sqrt {3}}{2}\right ) F\left (\sqrt {\frac {1+x}{\frac {3}{2}-\frac {i \sqrt {3}}{2}}}, \sqrt {\frac {-\frac {3}{2}+\frac {i \sqrt {3}}{2}}{-\frac {3}{2}-\frac {i \sqrt {3}}{2}}}\right )\right ) \sqrt {\left (1+x \right ) \left (x^{2}-x +1\right )}}{\sqrt {x^{3}+1}\, \sqrt {1+x}\, \sqrt {x^{2}-x +1}}\) \(223\)
default \(\frac {\sqrt {1+x}\, \sqrt {x^{2}-x +1}\, \left (3 i \sqrt {-\frac {2 \left (1+x \right )}{-3+i \sqrt {3}}}\, \sqrt {\frac {i \sqrt {3}-2 x +1}{i \sqrt {3}+3}}\, \sqrt {\frac {i \sqrt {3}+2 x -1}{-3+i \sqrt {3}}}\, F\left (\sqrt {-\frac {2 \left (1+x \right )}{-3+i \sqrt {3}}}, \sqrt {-\frac {-3+i \sqrt {3}}{i \sqrt {3}+3}}\right ) \sqrt {3}\, x +9 \sqrt {-\frac {2 \left (1+x \right )}{-3+i \sqrt {3}}}\, \sqrt {\frac {i \sqrt {3}-2 x +1}{i \sqrt {3}+3}}\, \sqrt {\frac {i \sqrt {3}+2 x -1}{-3+i \sqrt {3}}}\, F\left (\sqrt {-\frac {2 \left (1+x \right )}{-3+i \sqrt {3}}}, \sqrt {-\frac {-3+i \sqrt {3}}{i \sqrt {3}+3}}\right ) x -18 \sqrt {-\frac {2 \left (1+x \right )}{-3+i \sqrt {3}}}\, \sqrt {\frac {i \sqrt {3}-2 x +1}{i \sqrt {3}+3}}\, \sqrt {\frac {i \sqrt {3}+2 x -1}{-3+i \sqrt {3}}}\, E\left (\sqrt {-\frac {2 \left (1+x \right )}{-3+i \sqrt {3}}}, \sqrt {-\frac {-3+i \sqrt {3}}{i \sqrt {3}+3}}\right ) x -2 x^{3}-2\right )}{2 x \left (x^{3}+1\right )}\) \(363\)

[In]

int((1+x)^(1/2)*(x^2-x+1)^(1/2)/x^2,x,method=_RETURNVERBOSE)

[Out]

((1+x)*(x^2-x+1))^(1/2)/(1+x)^(1/2)/(x^2-x+1)^(1/2)*(-1/x*(x^3+1)^(1/2)+3*(3/2-1/2*I*3^(1/2))*((1+x)/(3/2-1/2*
I*3^(1/2)))^(1/2)*((x-1/2-1/2*I*3^(1/2))/(-3/2-1/2*I*3^(1/2)))^(1/2)*((x-1/2+1/2*I*3^(1/2))/(-3/2+1/2*I*3^(1/2
)))^(1/2)/(x^3+1)^(1/2)*((-3/2-1/2*I*3^(1/2))*EllipticE(((1+x)/(3/2-1/2*I*3^(1/2)))^(1/2),((-3/2+1/2*I*3^(1/2)
)/(-3/2-1/2*I*3^(1/2)))^(1/2))+(1/2+1/2*I*3^(1/2))*EllipticF(((1+x)/(3/2-1/2*I*3^(1/2)))^(1/2),((-3/2+1/2*I*3^
(1/2))/(-3/2-1/2*I*3^(1/2)))^(1/2))))

Fricas [C] (verification not implemented)

Result contains higher order function than in optimal. Order 9 vs. order 4.

Time = 0.08 (sec) , antiderivative size = 32, normalized size of antiderivative = 0.11 \[ \int \frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x^2} \, dx=-\frac {3 \, x {\rm weierstrassZeta}\left (0, -4, {\rm weierstrassPInverse}\left (0, -4, x\right )\right ) + \sqrt {x^{2} - x + 1} \sqrt {x + 1}}{x} \]

[In]

integrate((1+x)^(1/2)*(x^2-x+1)^(1/2)/x^2,x, algorithm="fricas")

[Out]

-(3*x*weierstrassZeta(0, -4, weierstrassPInverse(0, -4, x)) + sqrt(x^2 - x + 1)*sqrt(x + 1))/x

Sympy [F]

\[ \int \frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x^2} \, dx=\int \frac {\sqrt {x + 1} \sqrt {x^{2} - x + 1}}{x^{2}}\, dx \]

[In]

integrate((1+x)**(1/2)*(x**2-x+1)**(1/2)/x**2,x)

[Out]

Integral(sqrt(x + 1)*sqrt(x**2 - x + 1)/x**2, x)

Maxima [F]

\[ \int \frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x^2} \, dx=\int { \frac {\sqrt {x^{2} - x + 1} \sqrt {x + 1}}{x^{2}} \,d x } \]

[In]

integrate((1+x)^(1/2)*(x^2-x+1)^(1/2)/x^2,x, algorithm="maxima")

[Out]

integrate(sqrt(x^2 - x + 1)*sqrt(x + 1)/x^2, x)

Giac [F]

\[ \int \frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x^2} \, dx=\int { \frac {\sqrt {x^{2} - x + 1} \sqrt {x + 1}}{x^{2}} \,d x } \]

[In]

integrate((1+x)^(1/2)*(x^2-x+1)^(1/2)/x^2,x, algorithm="giac")

[Out]

integrate(sqrt(x^2 - x + 1)*sqrt(x + 1)/x^2, x)

Mupad [F(-1)]

Timed out. \[ \int \frac {\sqrt {1+x} \sqrt {1-x+x^2}}{x^2} \, dx=\int \frac {\sqrt {x+1}\,\sqrt {x^2-x+1}}{x^2} \,d x \]

[In]

int(((x + 1)^(1/2)*(x^2 - x + 1)^(1/2))/x^2,x)

[Out]

int(((x + 1)^(1/2)*(x^2 - x + 1)^(1/2))/x^2, x)